export function getSys() {
  let sys;
  let u = navigator.userAgent;
  let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
  if (isiOS) {
    sys = "ios";
  } else {
    sys = "android";
  }
  console.log("当前手机是" + sys + "操作系统");
  return sys;
}


/**
 * 获取操作系统的各种参数
 */
export function getDeviceInfo() {
  let deviceInfo = {};
  if(window.nativeMethod){
    let deviceJson = JSON.parse(window.nativeMethod.getNativeInfo());
    deviceInfo = {
      deviceId: deviceJson.deviceId,
      deviceName: deviceJson.deviceName,
      osVersion: deviceJson.osVersion,
      appMarket: deviceJson.appMarket,
      appVersion: deviceJson.appVersion
    }
  }
  return deviceInfo;
}

/**
 * 获取来自什么环境
 */
export function getFrom() {
  if(window.nativeMethod){
    return "app";
  }

  if(navigator){
    if(navigator.userAgent.match(/MicroMessenger/)){
      return "wx";
    }
    return "web"
  }
}
